
// https://leetcode.cn/problems/sum-of-all-subset-xor-totals/description/

class Solution
{
public:
    int sum;
    int path;

    int subsetXORSum(vector<int>& nums)
    {
        dfs(nums, 0);
        return sum;
    }

    void dfs(vector<int>& v, int idx)
    {
        sum += path;
        for (int i = idx; i < v.size(); ++i)
        {
            path ^= v[i];
            dfs(v, i + 1);
            path ^= v[i];
        }
    }
};